/**
 * 
 */
package com.ccrc.service;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.ccrc.lang.Pager;
import com.ccrc.dao.UserTabMapper;
import com.ccrc.model.UserTab;

/**
 * 用户管理，用管理用户信息 Service实现	
 * @author Jalen
 * @time 2017年03月30日 10:39
 *
 */
@Service
@Transactional(readOnly = true)
public class UserTabService implements IUserTabService {

	@Autowired
	private UserTabMapper userTabMapper;
	
	@Override
	public UserTab getUserTabByUserId(Long userId) {
		return userTabMapper.selectByPrimaryKey(userId);
	}

	@Override
	public void getPageUserTab(Pager pager) {
		List<UserTab> rets = userTabMapper.selectPage(pager.getCurPage(), pager.getPageSize());
		pager.setRows(rets);
		pager.setTotal(userTabMapper.selectTotal());
	}

	@Transactional
	@Override
	public void addUserTab(UserTab userTab) {
		userTabMapper.insert(userTab);
	}

	@Transactional
	@Override
	public void modifyUserTab(UserTab userTab) {
		userTabMapper.updateByPrimaryKey(userTab);
	}

	@Transactional
	@Override
	public void removeUserTab(Long userId) {
		userTabMapper.deleteByPrimaryKey(userId);
	}

	@Override
	public UserTab findUserTabByUserId(Long userId) {
		return userTabMapper.findByPrimaryKey(userId);
	}

	@Override
	public List<UserTab> getUserTabByAgeUserName(Integer age, String userName) {
		return userTabMapper.selectByAgeUserName(age, userName);
	}

	@Override
	public List<UserTab> findUserTabByGenderUserName(Integer gender, String userName) {
		return userTabMapper.findByGenderUserName(gender, userName);
	}

}